    /*
     * This is a technique I developed, but rarely use. However, as its an
     * interesting phenomenon, and relatively tidy (at least no messier than
     * Java's anonymous classes), I'm demonstrating it here.
     * 
     * Notice that we're declaring our class in the open, and that
     * its the traits provider only, thats being declared in a 'closure object'.
     * 
     * The self executing lambda idiom is well known in JavaScript communities:
     * 
     *     (function (argument)
     *     {
     *         alert(argument); // true
     *         alert(window === this); // true- executes in global scope
     *     })(true);
     *     
     * Finding that ugly, I discovered an alternative, like so
     * 
     *     new function (argument)
     *     {
     *         alert(argument); // true
     *         alert(window === this); // false- executes in an object scope
     *     }(true);
     *     
     * As all functions are constructors, invoking the above is practically
     * the same as evaluating 'new new Function', which will first create a 
     * function, then instantiate that function, creating an anonymous object.
     * 
     * The advantage is that we can create objects with private variables,
     * and coupled with ObjectKit extensions, define them in a relatively
     * clear way:
     * 
     *     var object= new function () 
     *     {
     *         var privateStatic= 0;
     *         this.constructor.implement
     *         (
     *             function getAndIncrementValue () 
     *             {
     *                 return privateStatic++;
     *             }
     *         );
     *     }
     *     
     * As ObjectKits #implement method treats any object provided to it as
     * a traits provider, we can paramaterise #implement with a closure object
     * and gain the benefits of a private static scope like below...
     * 
     */
    Class.implement 
    (
        
        /*
         * Create a new closure object, and define hidden methods in the
         * constructor. The returned object is then treated as a
         * traits provider, and its 'public' properties are implemented on 
         * Class.prototype
         */
        new function () 
        {
             // this is our hidden object- in OOP terms, this is actually
             // a static private member- all instances of Class have
             // access to the hidden object. We can add as many methods
             // as we want and none of them will be copied to the
             // Class.prototype
             var hidden= 
             {
                 getId: function () 
                 {
                     console.log('hidden method called in context: ' + this.id);
                     // notice that the execution scope of this method
                     // is an instance of Class- the id property is actually
                     // defined on the class instance, not the hidden object
                     return this.id;
                 }
             }
             
             // now we extend the traits providers prototype with the
             // properties we want to implement on Class.prototype
             // this is possible because the prototype is 'live'- that
             // is, modifications to the prototype updates all instances
             // of that prototype no matter when they were (or will be)
             // constructed. In this case, it means that anything we
             // implement here is passed on to the closure object, which
             // in turn will have its properties implemented on
             // Class.prototype
             this.constructor.implement
             (
                 
                 // define the methods and properties you want to implement
                 // on class in here as usual
                 
                 function getId () 
                 {
                     return hidden.getId.call(this);
                 }
             );   
        }
    );
    
    function Class (id) 
    {
        this.id= id;
    };
    
    
    var a= new Class ('a')
    ,   b= new Class ('b')


    alert(a.getId()); // a
    
    alert(b.getId()); // b           
    
    // The same technique can be used for static methods
    Singleton.inherit(Class).implementStatic
    (
         /* employ the same technique used above... */
        new function () 
        {
            
            /* a static private variable */
            var INSTANCE;
            
            /* implement the traits you want defined on the Singleton constructor... */
            this.constructor.implement
            (
                
                /**
                 * Get an instance of this singleton.
                 * @return {Singleton}
                 */
                function getInstance () 
                {
                    // note that we can access the static private INSTANCE
                    // variable and use it to store a reference to Singelton
                    if (this.is(INSTANCE))
                        return INSTANCE;
                    
                    // note that when this method is invoked that 'this' will 
                    // refer to the constructor   
                    return INSTANCE= new this; // wierd but legal EcmaScript
                }
                
                /**
                 * Determine if this Singleton has instantiated
                 * @return {Boolean}
                 */
            ,   function hasInstance () 
                {
                    // Again, note that 'this' will refer to the constructor
                    // when the hasInstance method is invoked.
                    return this.is(INSTANCE);
                }
            );   
        }
    );
    
    function Singleton () 
    {
        if (this.constructor.hasInstance())
            throw 'SingletonInstantiationError';
            
        Class.call(this, 'singletonId');
    };
    
    alert('hasInstance before instantiaion: ' + Singleton.hasInstance()); // false
    Singleton.getInstance();
    alert('hasInstance after instantiaion: ' + Singleton.hasInstance()); // true
    
    // notice that Singleton inherits Class, so therefore also inherits
    // the getId method- and this method calls a private method declared
    // in the closure object passed to Class.implement
    
    alert(Singleton.getInstance().getId());